<?php

	/**
	 * <summary>
	 * 	A documentor class for XML based documentation. Can work with items across a site
	 * 	including CSS, XML and HTML. Works natively in XMl and HTML
	 * </summary>
	 */	
	function ParseFile($sFile)
	{
		$sContainsConflitClass ='/(SuiteDocumentor)/';
		$sTrimComment = '/(^|\s) *\/?\*{1,2}\/? */';
		
		//push this off to another thread so we can load classes.
		$k =file_get_contents($sFile);
		if(preg_match_all($sContainsConflitClass, $k, $a)) {
			// Then you need to fork the process and run it side-by-side
			// otherwise use reflection
		}
		else {
			$b = get_declared_classes();
			include_once($sFile);
			
			$a = get_declared_classes();
			$aClass = array_diff($a, $b);
			
			foreach($aClass as $sClass) {
//				echo "Adding: $sClass<br />";
				$aReflectionClass[] =new ReflectionClass($sClass);
			}
			
			echo "<documentation>\n\n";
			foreach($aReflectionClass as $oReflection) {
				echo "\n\n<class>";
				echo '<name>'.$oReflection->name.'</name>';
				echo preg_replace($sTrimComment, '', $oReflection->getDocComment());
					foreach($oReflection->getMethods() as $oMethod) {
						echo '<method>';
						//echo "<br/><br />".var_dump($oMethod)."<br /><br />";
						echo '<name>'.$oMethod->name.'</name>';
						echo preg_replace($sTrimComment, '', $oMethod->getDocComment());
						foreach($oMethod->getParameters() as $oParameter) {
							echo '<parameter>';
							echo '<name>'.$oParameter->name.'</name>';
							echo '</parameter>';
						}
						echo '</method>';
					}
				echo "<class>\n\n";
			}
			echo "</documentation>";
		}
	}
?>